﻿Imports System.Windows.Forms

Public Class CustomerSearch
    Private lName As String = ""
    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub
    Public Sub New(ByVal customerName As String)
        Me.lName = customerName
        InitializeComponent()
    End Sub
    Private Sub CustomerSearch_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim getCustomer As New DAL
        Dim search As New GetCustomerByLastName
        Dim customers As New DataSet
        search.lName = Me.lName
        customers = getCustomer.GetCustomerByLastName(search)
        dgvCustomers.DataSource = customers.Tables(0)

    End Sub

    Private Sub dgvCustomers_RowHeaderMouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgvCustomers.RowHeaderMouseClick
        Dim index As Integer = -1
        index = e.RowIndex
        Dim editCust As New EditCustomer
        editCust.customerId = dgvCustomers.Rows(index).Cells(0).Value
        editCust.fName = dgvCustomers.Rows(index).Cells(1).Value
        editCust.lName = dgvCustomers.Rows(index).Cells(0).Value

    End Sub
End Class
